package com.bwie.controller;

import com.bwie.domain.TbProd;
import com.bwie.service.TbOrderService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2024/10/16 13:43
 */

@RestController
@RequestMapping(value = "/order/order")
public class TbOrderController {

    @Autowired
    TbOrderService tbOrderService;

    @PostMapping(value = "/buy")
    public R buy(@RequestBody ArrayList<TbProd> tbProds) {
        return tbOrderService.buy(tbProds);
    }

    @GetMapping(value = "/getUserById/{userId}")
    public R getUserById(@PathVariable("userId") Integer userId) {
        return tbOrderService.getUserById(userId);
    }

    @PostMapping(value = "/getOrderList")
    public R getOrderList(@Validated @RequestBody PageInfoVo pageInfoVo) {
        return tbOrderService.getOrderList(pageInfoVo);
    }

    @PostMapping(value = "/userPayByOrderId/{orderId}")
    public R userPayByOrderId(@PathVariable("orderId") Integer orderId) {
        return tbOrderService.userPayByOrderId(orderId);
    }

    /**
     * 获取商品销售总额
     * @return
     */
    @PostMapping(value = "/getProdSailAmount")
    public R getProdSailAmount() {
        return tbOrderService.getProdSailAmount();
    }

}
